<?php

/**
 * This is the model class for table "wajib_pajak".
 *
 * The followings are the available columns in table 'wajib_pajak':
 * @property integer $nomor
 * @property string $nama_pmk
 * @property string $no_op
 * @property string $nik_wp
 * @property string $nama_wp
 * @property string $alamat_wp
 * @property string $nama_kec
 * @property string $nama_kel
 * @property string $rt_wp
 * @property string $rw_wp
 * @property string $kab_wp
 * @property string $kode_pos
 */
class WajibPajak extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'wajib_pajak';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('nama_pmk, nama_wp', 'length', 'max'=>35),
			array('no_op, nik_wp', 'length', 'max'=>18),
			array('alamat_wp', 'length', 'max'=>50),
			array('nama_kec, nama_kel, kab_wp', 'length', 'max'=>15),
			array('rt_wp, rw_wp, kode_pos', 'length', 'max'=>5),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('nomor, nama_pmk, no_op, nik_wp, nama_wp, alamat_wp, nama_kec, nama_kel, rt_wp, rw_wp, kab_wp, kode_pos', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'nomor' => 'Nomor',
			'nama_pmk' => 'Nama Pmk',
			'no_op' => 'No Op',
			'nik_wp' => 'Nik Wp',
			'nama_wp' => 'Nama Wp',
			'alamat_wp' => 'Alamat Wp',
			'nama_kec' => 'Nama Kec',
			'nama_kel' => 'Nama Kel',
			'rt_wp' => 'Rt Wp',
			'rw_wp' => 'Rw Wp',
			'kab_wp' => 'Kab Wp',
			'kode_pos' => 'Kode Pos',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('nomor',$this->nomor);
		$criteria->compare('nama_pmk',$this->nama_pmk,true);
		$criteria->compare('no_op',$this->no_op,true);
		$criteria->compare('nik_wp',$this->nik_wp,true);
		$criteria->compare('nama_wp',$this->nama_wp,true);
		$criteria->compare('alamat_wp',$this->alamat_wp,true);
		$criteria->compare('nama_kec',$this->nama_kec,true);
		$criteria->compare('nama_kel',$this->nama_kel,true);
		$criteria->compare('rt_wp',$this->rt_wp,true);
		$criteria->compare('rw_wp',$this->rw_wp,true);
		$criteria->compare('kab_wp',$this->kab_wp,true);
		$criteria->compare('kode_pos',$this->kode_pos,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return WajibPajak the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
